#ifndef _AUDIO_H_
#define _AUDIO_H_

#include "fsl_sai_edma.h"

/* 语音前端相关宏定义 */
#define BUFFER_NUMBER			(2U) 
#define SAMP_FREQ			16000					/* 音频采样率 */
#define LEN_FRAM_MS			40					/* 帧长，单位ms */
#define DEMO_SAI			SAI1
#define NUM_FRAM_SAMPLE 		(LEN_FRAM_MS * SAMP_FREQ) / 1000 	/* 一帧采样点数 */
#define BUFFER_SIZE_BYTES		(NUM_FRAM_SAMPLE * 4) 			/* 一次采样需要的buffer是采样点数 * 2 * 2（2.556k）*/
#define AUDIO_BUFFER_LENGTH_MS 		(2000)
#define AUDIO_BUF_MAX_NUM_FRAMES	(AUDIO_BUFFER_LENGTH_MS / LEN_FRAM_MS)
#define AUDIO_BUFFER_LENGTH_SAMPLE	(AUDIO_BUFFER_LENGTH_MS * SAMP_FREQ) / 1000

extern uint8_t *rx_buf;
extern int16_t *audio_buf;
extern int16_t *pre_deal_buf;
extern volatile uint8_t flag_audio_buf;
extern volatile uint8_t start_point_flag;
extern sai_edma_handle_t txHandle;
extern sai_edma_handle_t rxHandle;
/* 测试用标志量 */
extern volatile uint8_t tx_over_flag;
/*
 * @brief 配置SAI的时钟和通道等
 */
extern void sai_edma_set(void);
/*
 * @brief 对音频数据进行预处理，取单声道数据
 * @param data_buf 输入原始音频数据
 */
extern void audio_data_pre_deal(int16_t *data_buf);

#endif
